﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using QuestionType = Zebra.Umbraco.Marcos.Code.QuestionType;
namespace Zebra.Umbraco.Marcos.Survey
{
    public partial class surveyPreview : System.Web.UI.UserControl
    {
        protected void Page_Load(object sender, EventArgs e)
        {
            if (!IsPostBack)
            {
                if (Request["SurveyID"] != null)
                {
                    using (DataClasses1DataContext db = new DataClasses1DataContext())
                    {
                        var questions = from question in db.surveyQuestions
                                        where question.surveyID == int.Parse(Request["SurveyID"])
                                        orderby question.surveyQuestionID
                                        select question;
                        foreach (surveyQuestion sQuestion in questions)
                        {
                            QuestionType.Question question = QuestionType.Question.FromXML(sQuestion.questionType, sQuestion.questionXML);
                            this.QuestionPanel.InnerHtml += question.GenerateHTML(false);
                        }

                    }
                }
            }
        }
    }
}